﻿using System;
using System.Threading.Tasks;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace BattleNet.D3.UnitTest
{
    /// <summary>
    /// 
    /// </summary>
    [TestClass]
    public class D3ServiceClientUnitTest
    {
        #region Client

        /// <summary>
        /// 
        /// </summary>
        private D3ServiceClient _serviceClient;

        #endregion

        #region Test Params

        /// <summary>
        /// 
        /// </summary>
        private string _battletagName;
        /// <summary>
        /// 
        /// </summary>
        private long _battletagCode;

        #endregion

        /// <summary>
        /// 
        /// </summary>
        public D3ServiceClientUnitTest()
        {
            this.Initialize();
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void Initialize()
        {
            this._serviceClient = new D3ServiceClient(Regions.EU, Localizations.de_DE);
            this._battletagName = "Asesjix";
            this._battletagCode = 2766;
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetProfile()
        {
            try
            {
                Profile profile = this._serviceClient.GetProfile(this._battletagName, this._battletagCode);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetProfileAsync()
        {
            try
            {
                Task<Profile> profileTask = this._serviceClient.GetProfileAsync(this._battletagName, this._battletagCode);
                profileTask.Wait();

                Profile profile = profileTask.Result;
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetHero()
        {
            try
            {
                Hero hero = this._serviceClient.GetHero(this._battletagName, this._battletagCode, 1655714);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetHeroAsync()
        {
            try
            {
                Task<Hero> heroTask = this._serviceClient.GetHeroAsync(this._battletagName, this._battletagCode, 1655714);
                heroTask.Wait();

                Hero hero = heroTask.Result;
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetItem()
        {
            try
            {
                ItemInformation itemInformation = this._serviceClient.GetItemInformation("item/CjkIwPWAzgQSBwgEFUd7JfwdhBydJx1NT9lkHcIayXsd1WaKlB1HCWKcHbJX1e4wCTi1AUAAUBJgpAIY8ZLUPVACWAA");
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetItemAsync()
        {
            try
            {
                Task<ItemInformation> ItemInformationTask = this._serviceClient.GetItemInformationAsync("item/CjkIwPWAzgQSBwgEFUd7JfwdhBydJx1NT9lkHcIayXsd1WaKlB1HCWKcHbJX1e4wCTi1AUAAUBJgpAIY8ZLUPVACWAA");
                ItemInformationTask.Wait();

                ItemInformation itemInformation = ItemInformationTask.Result;
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetFollower()
        {
            try
            {
                FollowerInformation followerInformation = this._serviceClient.GetFollowerInformation(FollowerTypes.enchantress);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetFollowerAsync()
        {
            try
            {
                Task<FollowerInformation> followerInformationTask = this._serviceClient.GetFollowerInformationAsync(FollowerTypes.enchantress);
                followerInformationTask.Wait();

                FollowerInformation followerInformation = followerInformationTask.Result;
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetArtisan()
        {
            try
            {
                ArtisanInformation artisanInformation = this._serviceClient.GetArtisanInformation(ArtisanTypes.blacksmith);
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        [TestMethod]
        public void GetArtisanAsync()
        {
            try
            {
                Task<ArtisanInformation> artisanInformationTask = this._serviceClient.GetArtisanInformationAsync(ArtisanTypes.blacksmith);
                artisanInformationTask.Wait();

                ArtisanInformation artisanInformation = artisanInformationTask.Result;
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
